# 是否安装app的处理
from common.adbtool import isinstallapk, installapk
from common.config import test_phone_type
from common.iosadbtool import iosisinstall, installios


def isinstallapp(apppackage:str,devicesName:str,apk_path:str)->bool:
    is_first_install = False
    # 1.判断是否安装app
    if test_phone_type == "Android":
        is_install = isinstallapk(apppackage, devicesName)
        if is_install is False:
            # 2.如果没有安装，则安装
            installapk(apk_path, devicesName)
            is_first_install = True
    elif test_phone_type == "IOS":
        is_install = iosisinstall(apppackage, devicesName)
        if is_install is False:
            # 2.如果没有安装，则安装
            installios(apppackage, devicesName)
            is_first_install = True

    return is_first_install